//
//  Status.m
//  weibo110
//
//  Created by 臧松 on 15/12/30.
//  Copyright © 2015年 臧松. All rights reserved.
//

#import "Status.h"
#import "User.h"
@implementation Status

+(instancetype)statusWithDict:(NSDictionary *)dict{
    
    return [[self alloc]initWithDict:dict];
}

-(instancetype)initWithDict:(NSDictionary *)dict{
    if ([super init]) {
        
        [self setValuesForKeysWithDictionary:dict];
    }
    
    return self;
}
-(void)setValue:(id)value forKey:(NSString *)key{
    if ([key isEqualToString:@"user"]&&(value != nil)) {
         self.user = [User userWithDict:value];
        
        return;
    }
    if ([key isEqualToString:@"retweeted_status"] && (value != nil)) {
        self.retweeted_status = [Status statusWithDict:value];
        
        return;
    }
    [super setValue:value forKey:key];
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{}

-(NSString *)description{
    
    NSArray * keys = @[@"id",@"text",@"created_at",@"source",@"user",@"pic_urls",@"retweeted_status"];
    
    return [self dictionaryWithValuesForKeys:keys].description;
}
@end
